package com.sunshine.lnuplus.utils

import android.appwidget.AppWidgetManager
import android.content.Context
import com.sunshine.lnuplus.R
import com.sunshine.lnuplus.model.WidgetData

/**
 * Created by sunshine on 2020/3/23
 */

object UpdateWidgetUtils {
    fun updateWidgets(context: Context) {
        WidgetData.initData(context)
        WidgetData.initTimetableView(context)
        WidgetData.initDayView(context)
        val widgetId = context.getSharedPreferences("widget_id", Context.MODE_PRIVATE)
        val appWidgetManager = AppWidgetManager.getInstance(context)
        widgetId.all.keys.forEach {
            appWidgetManager.notifyAppWidgetViewDataChanged(widgetId.getInt(it, 0), R.id.lesson_list_view)
        }
    }
}